﻿using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SystemServices;

namespace NLog使用
{
    internal class Program
    {
        static void Main(string[] args)
        {

            /*
            ServiceCollection services = new ServiceCollection();
            services.AddLogging(e => {
                e.AddConsole();
                // e.AddEventLog(); //插入到微软的事件查看器中
                e.SetMinimumLevel(LogLevel.Trace); //  设置日志输出级别  ，如果不设，输出就只有>=waring 
            });
            services.AddScoped<test1>();

            using (var sp = services.BuildServiceProvider())
            {
                var test1=sp.GetRequiredService<test1>();
                test1.WLog();
            }
            */


            // 日志存放到文本文档里
            ServiceCollection services = new ServiceCollection();
            services.AddLogging(e => {
                // e.AddConsole();
                e.AddNLog();
                e.SetMinimumLevel(LogLevel.Trace); //  设置日志输出级别  ，如果不设，输出就只有>=waring 
            });
            services.AddScoped<test1>();
            services.AddScoped<test2>();
            using (var sp = services.BuildServiceProvider())
            {
                var test1 = sp.GetRequiredService<test1>();
                test1.WLog();

                var test2=sp.GetRequiredService<test2>();
                test2.WLog();
            }

            // 结构化日志，集中化日志服务器


        }
    }
}
